[% setvar title Safe signal-handling for Perl. %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Safe signal-handling for Perl.</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Nathan Torkington &lt;<a href='mailto:gnat@frii.com'>gnat@frii.com</a>&gt;
  Date: 30 Jul 2000
  Version: 2
  Mailing List: perl6-internals
  Number: 1</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>The signal-handling mechanism in Perl 5 is not safe, but should be.
The two main candidates for implementation are delayed delivery via
checkpointing and the event loop.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>Signals may leave Perl in an inconsistent state, so that an inocuous
<code>print</code> in a signal handler might trigger a core-dump.  This is
referred to as &quot;unsafe signals&quot;.</p>
<p>Signal safety is crucial.  Signals are how timeouts, child process
deaths, and many other important things are conveyed to a program.
Many programs with operating-system interaction require signals,
and core-dumps are unacceptable.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>There are two choices for implementation: checkpointing, and event
loop. [Editor's note: the other RFC I refer to is fictitious]</p>
<a name='Checkpointing'></a><h2>Checkpointing</h2>
<p>If the Perl interpreter checkpointed itself at internally consistent
states, those states could be used to deliver signals.  This would
delay delivery, however, and the semantics of delayed signals might
make some programs impossible to write correctly.</p>
<a name='Event loop'></a><h2>Event loop</h2>
<p>RFC 6 describes a desired event loop mechanism.  If the existing
signal mechanism (%SIG) were dropped, signals could simply become
events that a program might or might not respond to.  This would be a
new model of signal handling which would make it difficult to reuse
algorithms and code for systems programming from C.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<pre>  RFC 6: &quot;Standard Event Loop&quot;
  perlvar manpage for discussion of %SIG</pre>
</div>
